fix: reject DEL character#842
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does
This PR addresses the bug where the
httpcrate accidentally allows the raw ASCIIDELcontrol character (0x7F) in URI paths and queries. It resurrects and updates the changes originally proposed in the dead PR #821.Context
PR #715 intentionally allowed raw UTF-8 to support all those web crawlers and browsers (like Google AppEngine, Safari, etc.) that send unescaped international characters. However, because the parser was checking the range
0x7F..=0xFF, the ASCIIDELcontrol character (0x7F) accidentally snuck through!But are those legitimate bots or browsers actually need to send a raw
DELcharacter? Leaving it open may cause parser differential/security issues downstream if a proxy handles a rawDELdifferently than this crate does.The Solution
By tweaking the range from
0x7F..=0xFFto0x80..=0xFF, we perfectly protect all the intended UTF-8 traffic while safely dropping and rejectingDELas an invalid control character.I have also included the regression tests (
rejects_del_in_pathandrejects_del_in_query) to make sure this stays fixed.A Quick Question for Maintainers
Is allowing
0x7Fhere actually intentional for some edge case I might be missing? I want to make sure I'm not talking nonsense or overlooking a specific design choice from #715. If this behavior is completely intentional, please let me know and I am more than happy to close this PR.Closes #820